package LocalClassifier;

import java.util.ArrayList;

import Definitions.GraphClass;
import Definitions.NodeClass;
import Global.GlobalClass;
import InputPreparer.InputPreparationMethodInterface;
import Sampling.SamplingAbstractClass;
import Utility.WorkerUtilityClass;

public class ExpertClassifierClass extends MachineLearningClassifiersClass{
	
	public ExpertClassifierClass(String name, ArrayList<InputPreparationMethodInterface> inputPrep, SamplingAbstractClass currentSampling, GlobalClass global) 
	{
		super(currentSampling, global);
		// TODO Auto-generated constructor stub
		this.inputPreparer=inputPrep;
		this.name=name;
		this.currentSampling = currentSampling;
	}
		
	public void train(GraphClass graph)  
	{
		System.out.println("I do not train, since i am an expert");
	}
	
	public double[] evaluate(NodeClass u, int stage, String s)
	{
		try {			
		
			int classLabelEstimated = u.getClassOrder();
			currentSampling.setClassLabelEstimated(u, (int)classLabelEstimated);
			
			double[] classLabelProbabilityDistribution = WorkerUtilityClass.getVectorForm(global.classSize, classLabelEstimated);
			/*System.out.println("classLabelProbabilityDistributionSize:"+classLabelProbabilityDistribution.length);
			
			for(int i=0; i<classLabelProbabilityDistribution.length; i++)
				System.out.print(classLabelProbabilityDistribution[i]+"  ");
			
			System.out.println("classLabelE:"+classLabelEstimated);*/
			return classLabelProbabilityDistribution;
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	
	public  ArrayList<Double> getInformationVector(NodeClass u, int whichNodesToUseForAggregation)
	{
		
		ArrayList<Double> input = new ArrayList<Double>(); 

		for(int i=0;  i<inputPreparer.size() ; i++)
		{
			
			ArrayList <Double> tempInput = inputPreparer.get(i).getInput(u, whichNodesToUseForAggregation);
			
			for(int j=0 ; j< tempInput.size() ; j++)
			{
				input.add(tempInput.get(j));
			}

			tempInput.clear();
		}
		return input;
	}
}
